package com.start;

public class XClassLoader extends ClassLoader {
	
	/**
	 * 
	 * @param className
	 * @param data data of class
	 * @return
	 */
	public synchronized Class<?> loadClassEx(String className, byte [] data)
			throws ClassNotFoundException{
		
		boolean resolve = false;
		
		Class<?> cls = null;

		if(data == null){
			return null;
		}

		// 4. turn the byte array into a Class
		try {
			cls = defineClass(className, data, 0, data.length);
			if (resolve) {
				resolveClass(cls);
			}
		} catch (SecurityException e) {
			// loading core java classes such as java.lang.String
			// is prohibited, throws java.lang.SecurityException.
			// delegate to parent if not allowed to load class
//			cls = super.loadClass(className, resolve);
		}

		return cls;
		
	}

	@Override
	protected synchronized Class<?> loadClass(String className, boolean resolve)
			throws ClassNotFoundException {

		return super.loadClass(className, resolve);
	}


}
